from rest_framework.viewsets import ModelViewSet
from rest_framework.response import Response

from component import models
from component.serializers import ComponentType, ComponentRenderType, Component


# Create your views here.

class ComponentTypeView(ModelViewSet):
    """
    组件类型的视图
    """
    queryset = models.ComponentType.objects.all().order_by("-id")
    serializer_class = ComponentType.ComponentTypeSerializer


class ComponentRenderTypeView(ModelViewSet):
    """
    组件渲染类型的视图
    """
    queryset = models.ComponentRenderType.objects.all().order_by("-id")
    serializer_class = ComponentRenderType.ComponentRenderTypeSerializer


class ComponentView(ModelViewSet):
    """
    组件的视图
    """
    queryset = models.Component.objects.order_by("-id")
    serializer_class = Component.ComponentSerializer
